﻿using Inovout.Cloud.Messager.Domain;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Cloud.Messager.Until
{
    public class SendMsg
    {

        private string Server = "http://112.74.76.186";
        private string Port = ":8030";
        private string Path = "/service/httpService/httpInterface.do";
        //public string ImmediateSeng(Message msg)
        //{
        //    HttpWebRequest request = null; ;
        //    //订单上传测试
        //    string url = String.Format("{0}{1}{2}", Server, Port, Path);
        //    string param = "";
        //    param = "method=" + msg.Method + "&username=" + msg.UserName + "&password=" + msg.PassWord + "&veryCode=" + msg.VeryCode + "&mobile=" + msg.Mobile + "&content=" + msg.Content + "&msgtype=" + msg.MsgType + "&tempid=" + msg.Tempid;
        //    byte[] bs = Encoding.UTF8.GetBytes(param);
        //    request = WebRequest.Create(url) as HttpWebRequest;
        //    request.Method = "POST";
        //    request.ContentType = "application/x-www-form-urlencoded";
        //    request.ContentLength = bs.Length;
        //    using (Stream res = request.GetRequestStream())
        //    {
        //        res.Write(bs, 0, bs.Length);
        //        res.Close();
        //    }
        //    string str = "";
        //    using (WebResponse wr = request.GetResponse())
        //    {
        //        Stream st = wr.GetResponseStream();
        //        str = new StreamReader(st, System.Text.Encoding.UTF8).ReadToEnd();
        //    }
        //    return str;
        //}
        public static string GetJson(object obj)
        {
            var iSetting = new JsonSerializerSettings();
            iSetting.NullValueHandling = NullValueHandling.Ignore;
            return Newtonsoft.Json.JsonConvert.SerializeObject(obj, iSetting);
        }
    }
}
